﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.IO;

namespace TuiTest
{
    static class SdfFile
    {
        internal static string GetFile()
        {
            return GetFile(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory);
        }
        private static string GetFile(DirectoryInfo startDirectory)
        {
            if (startDirectory == null) throw new Exception(@"Could not find file 'Northwind.sdf', try copying it from 'C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Samples\Northwind.sdf' to the application directory.");
            var f = startDirectory.GetFiles("Northwind.sdf");
            if (f.Length > 0) return f[0].FullName;
            return GetFile(startDirectory.Parent);
        }
    }
}
